package alexandria.dashboard.entity

import grails.test.*

class ProjectTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testConstraints() {
        mockDomain Project
        def project = new Project()
        assertFalse(project.validate())
        def project_ok = new Project(
            externalId: "1234",
            name: 'Dashboard', 
            description: 'Módulo para visão gerencial de projetos',
            owner: 'rise '
            )
            assertTrue( project_ok.validate())
    }
    
    void testeUnicidade(){
        mockDomain Project, []
        def project1 = new Project( 
                                    externalId: '1234', 
                                    name: 'Dashboard', 
                                    description: 'Módulo para visão gerencial de projetos',
                                    owner: 'rise')
        project1.save()
        def project2 = new Project( name: 'Dashboard', 
                                    externalId: '5678', 
                                    description: 'Módulo 2 para visão gerencial de projetos',
                                    owner: 'rise2')
        assertFalse(project2.validate())
        def project3 = new Project( name: 'Dashboard2', 
                                    externalId: '1234', 
                                    description: 'Módulo 2 para visão gerencial de projetos',
                                    owner: 'rise2')
        assertFalse(project3.validate())
    }
}
